package br.com.unibratec.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import br.com.unibratec.negocio.Evento;
import br.com.unibratec.negocio.EventoDAO;
import br.com.unibratec.receiver.WidgetProvider;
import br.com.unibratec.service.WidgetService;

public class MostrarActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (this.getIntent().getSerializableExtra("evento") != null) {
            int notifcacaoId = this.getIntent().getIntExtra("notifcacaoId", 0);

            Evento evento = (Evento) this.getIntent().getSerializableExtra(
                    "evento");
            TextView txt = new TextView(this);
            txt.setText(notifcacaoId + " - " + evento.getDescricao() + " - "
                    + evento.getData());
            this.setContentView(txt);

            evento.setAtivo(false);
            EventoDAO.getInstace(this).atualizar(notifcacaoId, evento);

            WidgetProvider.printLog("MostrarActivity: "
                    + evento.toStringLogCat());

            Intent it = new Intent(this, WidgetService.class);
            it.setAction(WidgetService.ACTION_LOAD_DATA);
            this.startService(it);
        }
    }
}
